package com.clickpaas.timelineofUN.dao.Impl;

import com.bizcloud.ipaas.t7aef1c33e4a445f2833f9d631cb90c38.d20210202091529.codegen.UpdatedynamicsApi;
import com.bizcloud.ipaas.t7aef1c33e4a445f2833f9d631cb90c38.d20210202091529.model.*;
import com.clickpaas.timelineofUN.bean.TimelineDTOBean;
import com.clickpaas.timelineofUN.dao.UpdatedynamicsDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Repository
public class UpdatedynamicsDaoImpl implements UpdatedynamicsDao {

    @Resource
    private TimelineDTOBean timelineDtoBean;
    @Resource
    private UpdatedynamicsApi updatedynamicsApi;
    /**
     * 查询动态更新数据By projectId
     *
     * @param updateDynamicsDTO
     * @return
     */
    @Override
    public List<UpdateDynamicsDTOResponse> getUpdateNamicsByProId(UpdateDynamicsDTO updateDynamicsDTO) {
        DataResponseListUpdateDynamicsDTO updateDynamicsUsingInfo = updatedynamicsApi.findUpdateDynamicsUsingPOST(updateDynamicsDTO);
        if (null == updateDynamicsUsingInfo
                || null == updateDynamicsUsingInfo.getData()
                || !"SUCCESS".equals(updateDynamicsUsingInfo.getMessage()))
            return null;
        return updateDynamicsUsingInfo.getData();
    }

    /**
     * 查询动态更新数据 byProjectId
     *
     * @param projectId
     * @return
     */
    @Override
    public List<UpdateDynamicsDTOResponse> getUpdateNamicsByProId(String projectId) {
        UpdateDynamicsDTO updateDynamics = timelineDtoBean.updateDynamicsDTO();
        updateDynamics.setProject(projectId);
        return getUpdateNamicsByProId(updateDynamics);
    }
}
